package com.ruoyi.web.lccl.service.impl;

import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.web.gd.domain.OrderInfo;
import com.ruoyi.web.gd.mapper.OrderInfoMapper;
import com.ruoyi.web.gj.domain.WarningInfo;
import com.ruoyi.web.gj.mapper.WarningInfoMapper;
import com.ruoyi.web.lccl.domain.Lccl;
import com.ruoyi.web.lccl.mapper.YjLcclMapper;
import com.ruoyi.web.lccl.service.YjILcclService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 流程处理信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-24
 */
@Service
public class YjLcclServiceImpl implements YjILcclService
{
    @Autowired
    private YjLcclMapper lcclMapper;
    @Autowired
    private OrderInfoMapper orderInfoMapper;
    @Autowired
    private WarningInfoMapper warningInfoMapper;

    /**
     * 新增流程处理信息
     *
     * @param lccl 流程处理信息
     * @return 结果
     */
    @Override
    public int insertLccl(Lccl lccl)
    {
        lccl.preInsert();
        lccl.setId(IdUtils.randomUUID());
        return lcclMapper.insertLccl(lccl);
    }

    /**
     * 新增流程处理信息
     *
     * @param lccl 流程处理信息
     * @return 结果
     */
    @Override
    public int addLccl(Lccl lccl)
    {
        OrderInfo orderInfo=orderInfoMapper.selectOrderInfoById(Long.valueOf(lccl.getWorkId()));
        orderInfo.setCreateBy(lccl.getClrmc());
        orderInfoMapper.updateOrderInfo(orderInfo);

        //状态改为转发
        WarningInfo warningInfo=new WarningInfo();
        warningInfo.setId(Long.valueOf(lccl.getYjid()));
        warningInfo.setClzt("3");
        warningInfoMapper.updateWarningInfo(warningInfo);
        lccl.preInsert();
        Lccl lcclParam=new Lccl();
        lcclParam.setWorkId(lccl.getWorkId());
        Lccl lccl1=lcclMapper.getLcclOne(lcclParam);
        lccl1.preUpdate();
        lccl1.setClyj(lccl.getClyj());
        lcclMapper.updateLccl(lccl1);
        lccl.setClyj("");
        return lcclMapper.insertLccl(lccl);
    }

    @Override
    public List<Lccl> selectLcclList(Lccl lccl)
    {
        return lcclMapper.selectLcclList(lccl);
    }

}
